#include "StdAfx.h"

CommandUI* Singleton<CommandUI>::m_instance = 0;

CommandUI::CommandUI()
{
	m_dialog = new Dialog(sD3D.GetSize().x - 200, 100, 5, 8, "Functions", false);
	pTerrain = m_dialog->AddCheckbox(this, 15, 30, "Terrain", &CommandUI::CheckboxProc);
	pTexture = m_dialog->AddCheckbox(this, 15, 60, "Texturing", &CommandUI::CheckboxProc);
	pShader = m_dialog->AddCheckbox(this, 15, 90, "Shading", &CommandUI::CheckboxProc);
	pTerrain->SetChecked(true);
	sUI.AddElement(m_dialog);
}

void CommandUI::TexQuadProc(TextureQuad<CommandUI>* pQuad)
{
	sSelection.ShowTextureSelection();
}

void CommandUI::SetActiveTexture(std::string szTexture)
{
	m_dialog->ResetQuads();
	m_dialog->AddTexQuad(this, &CommandUI::TexQuadProc, szTexture, Vertex2F(25, 125), 110)->visible = true;
}

void CommandUI::CheckboxProc(Checkbox<CommandUI>* pBox, ui32 checked)
{
	if(!checked)
	{
		pBox->m_state = 1;
		return;
	}
	if(pBox == pTerrain)
	{
		pTexture->m_state = 0;
		pShader->m_state = 0;
	}
	else if(pBox == pTexture)
	{
		pTerrain->m_state = 0;
		pShader->m_state = 0;
		sSelection.EnableTexturing();
	}
	else if(pBox == pShader)
	{
		pTerrain->m_state = 0;
		pTexture->m_state = 0;
		sSelection.EnableMCCV();
		sShader.Show();
	}
}